<template>
  <div>
    <div v-for="(item,index) in data" class="el-container card-container" :class="{'active':activeIndex==index}" @click="handleClick(index)">
      <div class="card-pic">
        <img style="width:3.4rem;height:3.4rem" :src="item.iconUrl || require('@/assets/images/sjjr_jrsjy_all.png')" alt="">
      </div>
      <div class="card-text">
        <p class="card-title">{{ item.name }}</p>
        <p class="card-sub-title"><span>数据源:</span><span class="card-num">{{ item.num }}</span></p></div>
    </div>
  </div>

</template>

<script>
export default {
  name: 'TabList',
  props: {
    data: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      activeIndex: 0
    }
  },
  methods: {
    handleClick(index) {
      this.activeIndex = index
      this.$emit('handleClick', index)
    }
  }
}
</script>

<style lang="scss" scoped>
.card-container{
  display:flex;
  justify-content: space-around;
  align-items: center;
  padding:5px 10px;
  border:1px solid #e8e8e8;
  border-radius:4px;
  margin-bottom:10px;
  cursor: pointer;
}
.active{
  border-color:#2979ff;
  background:#e4eeff;
}
.card-num{color:#2979ff}
</style>
